Skip to content

Comments

thread movement & context menu#498

Merged
MrgSub merged 18 commits intostagingfrom
thread-movement
Mar 21, 2025
Merged

thread movement & context menu#498
MrgSub merged 18 commits intostagingfrom
thread-movement

Conversation

@hiheyhello123
Copy link
Contributor

@hiheyhello123 hiheyhello123 commented Mar 21, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced archive search now provides more precise query results.
    • Improved thread management allows seamless movement of emails between Inbox, Spam, and Archive.
    • Bulk selection resets automatically when switching folders for a cleaner experience.
    • The Archive section in navigation is now enabled for easier access.
    • New user interface labels for replying, forwarding, and managing labels have been added.
    • Highlighting functionality for specific text in email content has been introduced.
  • Bug Fixes

    • Resolved issues with context menu interactions for thread management.

@hiheyhello123 hiheyhello123 requested a review from MrgSub March 21, 2025 00:14
@vercel
Copy link

vercel bot commented Mar 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2025 7:08pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request enhances the mail application’s functionality by improving query handling and thread management. The update includes an adjustment in the Gmail driver to handle archive folder searches, introduces a new thread-moving mechanism via a moveThreadsTo function, adds a context menu for threads with updated props, and revises the bulk selection logic with a new atom. Additionally, the navigation configuration is changed to enable the archive folder. All changes are integrated across various components and utility modules to streamline thread actions and UI interactions.

Changes

Files Change Summary
apps/mail/app/.../driver/google.ts Added a conditional in normalizeSearch to handle "archive" by returning folder: undefined and a query formatted as in:archive ${q}.
apps/mail/components/context/thread-context.tsx, apps/mail/components/mail/mail-list.tsx, apps/mail/components/mail/mail.tsx, apps/mail/components/mail/thread-display.tsx, apps/mail/lib/thread-actions.ts Introduced new thread movement functionality: replaced label modifications with the moveThreadsTo function, integrated a ThreadContextMenu wrapper, updated component props (adding folder and onRefresh), and provided contextual dropdown actions based on the current folder.
apps/mail/components/mail/use-mail.ts, apps/mail/components/ui/nav-main.tsx Added and implemented clearBulkSelectionAtom to reset bulk selections, including invoking it on navigation clicks to clear UI state.
apps/mail/config/navigation.ts Removed the disabled: true property from the archive navigation item, enabling user interaction with the archive folder.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant TCM as ThreadContextMenu
    participant MTA as moveThreadsTo
    participant ML as modifyLabels (API)
    U->>TCM: Select thread action (e.g., Archive)
    TCM->>MTA: Invoke moveThreadsTo with thread IDs and destination
    MTA->>ML: Call modifyLabels with label changes
    ML-->>MTA: Return status (success/error)
    MTA-->>TCM: Return result and trigger state updates
    TCM-->>U: Update UI with new thread state
Loading
sequenceDiagram
    participant U as User
    participant NI as NavItem
    participant CSA as clearBulkSelectionAtom
    U->>NI: Click navigation item
    NI->>CSA: Invoke atom setter to clear bulk selection
    CSA-->>NI: Selection cleared
    NI-->>U: Proceed with navigation action
Loading

Suggested reviewers

  • nizzyabi
  • ahmetskilinc

Poem

In the code warren where emails hop and twirl,
I’ve refined the search for every archive swirl.
Threads now dance with a new, smooth flow,
And bulk selections vanish—watch them go!
With each small change a joyful beat,
This rabbit cheers our code so sweet! 🐇
Hoppity code, let enhancements repeat!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7341e71 and 74bece1.

📒 Files selected for processing (12)
  • apps/mail/app/(routes)/mail/page.tsx (0 hunks)
  • apps/mail/app/api/driver/google.ts (1 hunks)
  • apps/mail/components/context/thread-context.tsx (5 hunks)
  • apps/mail/components/draft/drafts-list.tsx (1 hunks)
  • apps/mail/components/mail/mail-list.tsx (5 hunks)
  • apps/mail/components/mail/mail.tsx (8 hunks)
  • apps/mail/components/mail/thread-display.tsx (6 hunks)
  • apps/mail/components/mail/thread-subject.tsx (1 hunks)
  • apps/mail/hooks/use-threads.ts (4 hunks)
  • apps/mail/lib/email-utils.client.tsx (1 hunks)
  • apps/mail/locales/en.json (1 hunks)
  • apps/mail/types/index.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hiheyhello123 hiheyhello123 marked this pull request as draft March 21, 2025 12:01
@hiheyhello123 hiheyhello123 marked this pull request as ready for review March 21, 2025 18:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/mail/components/mail/mail.tsx (1)

379-391: Unnecessary Fragment wrapper can be simplified.

The Fragment (empty tags) wrapping the ResizablePanel is redundant since there's only a single child element.

-					{isDesktop && threadIdParam && (
-						<>
-							<ResizablePanel
-								className="bg-offsetLight dark:bg-offsetDark shadow-sm md:flex md:rounded-2xl md:border md:shadow-sm"
-								defaultSize={75}
-								minSize={25}
-							>
-								<div className="relative hidden h-[calc(100vh-(12px+14px))] flex-1 md:block">
-									<ThreadDisplay onClose={handleClose} mail={threadIdParam} />
-								</div>
-							</ResizablePanel>
-						</>
-					)}
+					{isDesktop && threadIdParam && (
+						<ResizablePanel
+							className="bg-offsetLight dark:bg-offsetDark shadow-sm md:flex md:rounded-2xl md:border md:shadow-sm"
+							defaultSize={75}
+							minSize={25}
+						>
+							<div className="relative hidden h-[calc(100vh-(12px+14px))] flex-1 md:block">
+								<ThreadDisplay onClose={handleClose} mail={threadIdParam} />
+							</div>
+						</ResizablePanel>
+					)}
🧰 Tools
🪛 Biome (1.9.4)

[error] 380-390: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c15f54 and 7341e71.

📒 Files selected for processing (7)
  • apps/mail/app/api/driver/google.ts (1 hunks)
  • apps/mail/components/context/thread-context.tsx (5 hunks)
  • apps/mail/components/mail/mail-list.tsx (4 hunks)
  • apps/mail/components/mail/mail.tsx (8 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
  • apps/mail/components/ui/nav-main.tsx (4 hunks)
  • apps/mail/locales/en.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/mail/components/ui/nav-main.tsx
  • apps/mail/app/api/driver/google.ts
  • apps/mail/components/context/thread-context.tsx
🧰 Additional context used
🧬 Code Definitions (2)
apps/mail/components/mail/mail-list.tsx (5)
apps/mail/components/mail/use-mail.ts (1) (1)
  • useMail (15-17)
apps/mail/lib/utils.ts (2) (2)
  • FOLDERS (8-15)
  • formatDate (65-106)
apps/mail/components/context/thread-context.tsx (1) (1)
  • ThreadContextMenu (56-278)
apps/mail/lib/notes-utils.ts (1) (1)
  • formatDate (72-89)
apps/mail/components/mail/empty-state.tsx (1) (1)
  • FolderType (27-27)
apps/mail/components/mail/mail.tsx (4)
apps/mail/components/mail/use-mail.ts (2) (2)
  • useMail (15-17)
  • clearBulkSelectionAtom (19-25)
apps/mail/hooks/use-threads.ts (1) (1)
  • useThreads (68-112)
apps/mail/hooks/use-stats.ts (1) (1)
  • useStats (6-19)
apps/mail/lib/thread-actions.ts (3) (3)
  • getAvailableActions (42-45)
  • ThreadDestination (6-6)
  • moveThreadsTo (47-103)
🪛 Biome (1.9.4)
apps/mail/components/mail/mail.tsx

[error] 380-390: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (18)
apps/mail/locales/en.json (1)

208-214: Locale entries added for thread movement and context menu functionality.

Good addition of necessary locale strings for the thread management capabilities. The new keys support the UI elements for replying, forwarding, and label management.

apps/mail/components/mail/mail-list.tsx (5)

8-8: New ThreadContextMenu import for enhanced thread interaction.

The addition of the ThreadContextMenu component establishes the foundation for the right-click context menu functionality on threads.


46-58: Thread component extended with folder context support.

The component signature has been enhanced to include folder identification and refresh callback, allowing for folder-specific thread operations.


68-70: Folder type determination using constants.

Good use of the FOLDERS constants for logical folder type checks, making the code more maintainable and less prone to string comparison errors.


130-208: Thread component now wrapped with context menu.

The Thread component rendering is now enhanced with the ThreadContextMenu wrapper, which receives appropriate props for handling thread-specific actions based on the current folder.


447-473: Updated component structure for empty state handling.

The refactored code now properly handles empty states and filtering conditions, providing appropriate UI feedback based on the content state.

apps/mail/components/mail/thread-display.tsx (6)

4-4: Added useParams for folder context awareness.

Good addition of the useParams hook to obtain the current folder, enabling folder-specific functionality.


8-8: Integrated thread movement capabilities.

The moveThreadsTo functionality imported from thread-actions.ts provides the core functionality for moving threads between folders.


208-211: Added folder type detection for contextual actions.

These logical checks determine the current folder type, which is essential for showing or hiding relevant actions in the UI.


216-230: Implemented moveThreadTo function for thread relocation.

Well-structured function that handles thread movement with proper success callback chain, ensuring both thread data and stats are updated after a successful move operation.


375-378: Added conditional rendering for Archive action.

The Archive button is now properly disabled when not in inbox or spam folders, ensuring actions are only available when contextually relevant.


399-413: Implemented conditional menu items based on folder.

The dropdown menu now intelligently displays relevant actions based on the current folder context, improving the user experience by showing only appropriate options.

apps/mail/components/mail/mail.tsx (6)

13-17: Imported thread action utilities.

Good addition of the necessary imports for thread movement and action availability checks, which centralizes the thread manipulation logic.


34-34: Added clearBulkSelectionAtom for selection management.

This atom provides a clean way to reset bulk selections when needed, keeping the UI state consistent.


209-214: Implemented folder change detection to clear selections.

Good use of useEffect to reset bulk selection when navigating between folders, which prevents user confusion and ensures a clean state.


452-466: Added bulk thread movement with state updates.

Well-implemented success callback that properly updates thread data, statistics, and clears selections after a thread move operation completes.


467-481: Created dynamic action mappings for thread operations.

Good approach using a mapping object for action buttons, making it easy to add new actions in the future while maintaining consistent styling and behavior.


526-548: Implemented dynamic action button generation.

Excellent pattern for generating action buttons based on available actions for the current folder context. This approach is maintainable and automatically adapts to different folder states.

@MrgSub MrgSub merged commit 0427c7c into staging Mar 21, 2025
3 of 5 checks passed
This was referenced Apr 5, 2025
@BlankParticle BlankParticle deleted the thread-movement branch May 25, 2025 13:42
@coderabbitai coderabbitai bot mentioned this pull request Jun 20, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants